package com.hanbang.qzzds.view.home.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;

import com.hanbang.qzzds.R;
import com.hanbang.qzzds.appliction.base.baseadapter.ViewHolder;
import com.hanbang.qzzds.appliction.base.baseadapter.recyclerview.CommonAdapter;
import com.hanbang.qzzds.appliction.base.view.activity.BaseMainActivity;
import com.hanbang.qzzds.mode.javabean.base.UserData;
import com.hanbang.qzzds.pressenter.home.HomePresenter;
import com.hanbang.qzzds.view.home.iview.IHomeView;
import com.hanbang.qzzds.view.widget.ListSwipeView;
import com.hanbang.qzzds.view.widget.autoloadding.StatusChangListener;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import butterknife.BindView;

/**
 * 作者　　: 李坤
 * 创建时间:2016/9/19　17:04
 * 邮箱　　：496546144@qq.com
 * <p>
 * 功能介绍：
 */

public class HomeActivity extends BaseMainActivity<IHomeView, HomePresenter> implements IHomeView {


    @BindView(R.id.switchRoot)
    protected ListSwipeView listSwipeView;
    CommonAdapter adapter;
    private List<UserData> listDatas = new ArrayList<>();


    public static void startUI(Activity activity) {
        Intent intent = new Intent(activity, HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getContentView() {
        return R.layout.activity_home;
    }

    @Override
    public HomePresenter initPressenter() {
        return new HomePresenter();
    }

    @Override
    public void clearData() {

    }




    @Override
    public void initView() {
        super.initView();
        toolbar.setTitle("首页");
        presenter.getHttpData(true);
        listSwipeView.setAdapter(adapter = new CommonAdapter<UserData>(this,R.layout.aaa,listDatas) {
            @Override
            public void convert(ViewHolder holder, UserData o) {

            }

        });
    }

    @Override
    public void parseIntent(Intent intent) {

    }

    @Override
    public int currentItem() {
        return 0;
    }

    @Override
    public void upDataUI() {
        adapter.notifyDataSetChanged();
    }
    @Override
    public StatusChangListener getStatusChangListener() {
        return listSwipeView.getStatusChangListener();
    }

    @Override
    public <T> Collection<T> getValidData(Collection<T> c) {
        return listSwipeView.getValidData(c);
    }

    @Override
    public void clearPagingData() {
        listSwipeView.getPagingHelp().clear();

    }

    @Override
    public int getPageindex() {
        return listSwipeView.getPagingHelp().getPageindex();
    }

    @Override
    public int getPageCount() {
        return listSwipeView.getPagingHelp().getPageCount();
    }

    @Override
    public SwipeRefreshLayout getSwipeRefreshLayout() {
        return listSwipeView.getSwipeRefreshLayout();
    }

    @Override
    public void onRefresh() {

    }


}
